#include<stdio.h>

int main()
{
	int a = 0;
	int b = 0;
	scanf_s("%d %d", &a, &b);
	int m= (a < b) ? a : b;
	

	while (1)
	{
		if (a % m == 0 && b % m == 0)
		{
			break;
			m--;
		}
	}
	printf("%d\n", m);
		return 0;
}